#include "..\\include\Lib_Clara.h"
#include "..\\include\Dir.h"
#include "gui.h"

void GuiBack(BOOK *bk, void *lt)
{  
  FreeBook((BOOK*)myBook);
}

void GuiOnEnterPressed(BOOK *bk, void *lt)
{     
  int item=ListMenu_GetSelectedItem(myBook->gui);
  if(item==0)
      MessageBox(0x6fFFFFFF,STR("Element 1"),0, 1 ,5000,0);
  if(item==1)
      MessageBox(0x6fFFFFFF,STR("Element 2"),0, 1 ,5000,0);
  if(item==2)
    MessageBox(0x6fFFFFFF,STR("Element 3"),0, 1 ,5000,0);
}

int GuiOnLBMessage(GUI_MESSAGE * msg)
{
  int item;  
  switch(msg->msg)
  {    
  case 1:
    item=GUIonMessage_GetCreatedItemIndex(msg);    
    if(item==0)    
      SetMenuItemText0(msg,Str2ID(L"Menu 1",0,SID_ANY_LEN));  
    if(item==1)    
      SetMenuItemText0(msg,Str2ID(L"Menu 2",0,SID_ANY_LEN)); 
    if(item==2)
      SetMenuItemText0(msg,Str2ID(L"Menu 3",0,SID_ANY_LEN)); 
  }
  return(1);
};

void GuiCreateGuiList(void * r0, BOOK * bk, wchar_t * GUI_NAME, int ItemNumber)
{  
  myBook->gui=CreateListObject(bk,0);
  GuiObject_SetTitleText(myBook->gui,Str2ID(GUI_NAME,0,SID_ANY_LEN));
  SetNumOfMenuItem(myBook->gui,ItemNumber);
  OneOfMany_SetonMessage((GUI_ONEOFMANY*)myBook->gui,GuiOnLBMessage);
  SetCursorToItem(myBook->gui,0);
  SetMenuItemStyle(myBook->gui,0);
  GUIObject_Softkey_SetAction(myBook->gui,ACTION_BACK, GuiBack);  
  GUIObject_Softkey_SetAction(myBook->gui,ACTION_LONG_BACK, GuiBack);  
  GUIObject_Softkey_SetAction(myBook->gui,ACTION_SELECT1,GuiOnEnterPressed);     
  ShowWindow(myBook->gui);  
};
